home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol K-12 / Vol K-12.iso / interfac / it.dig / scripts / FSelectableItemSymbol.as < prev    next >
Text File  |  2012-08-27  |  4KB  |  135 lines

  1. function FSelectableItemClass()
  2. {
  3.    this.init();
  4. }
  5. FSelectableItemClass.prototype = new FUIComponentClass();
  6. FSelectableItemClass.prototype.init = function()
  7. {
  8.    if(this._name != "itemAsset")
  9.    {
  10.       this.highlighted = false;
  11.       this.layoutContent(100);
  12.    }
  13. };
  14. FSelectableItemClass.prototype.drawItem = function(itmObj, selected)
  15. {
  16.    this.displayContent(itmObj,selected);
  17.    if(this.highlighted != selected || this.controller.focused != this.oldFocus && selected)
  18.    {
  19.       this.setHighlighted(selected);
  20.    }
  21.    this.oldFocus = this.controller.focused;
  22. };
  23. FSelectableItemClass.prototype.setSize = function(width, height)
  24. {
  25.    var _loc2_ = -16384;
  26.    this.width = width;
  27.    this.layoutContent(width);
  28.    this.attachMovie("FHighlightSymbol","highlight_mc",_loc2_);
  29.    this.highlight_mc._x = 0.5;
  30.    this.highlight_mc._width = width - 0.5;
  31.    this.highlight_mc._height = height;
  32.    this.highlight_mc.controller = this;
  33.    this.highlight_mc._alpha = 0;
  34.    this.highlight_mc.trackAsMenu = true;
  35.    this.highlight_mc.onPress = function()
  36.    {
  37.       if(this.controller.enable)
  38.       {
  39.          this.controller.controller.clickHandler(this.controller.itemNum);
  40.       }
  41.    };
  42.    this.highlight_mc.onDragOver = function()
  43.    {
  44.       if(this.controller.controller.focused)
  45.       {
  46.          this.onPress();
  47.       }
  48.    };
  49.    this.highlight_mc.useHandCursor = false;
  50.    this.highlight_mc.trackAsMenu = true;
  51. };
  52. FSelectableItemClass.prototype.setEnabled = function(enabledFlag)
  53. {
  54.    this.enable = enabledFlag;
  55.    this.fLabel_mc.setEnabled(enabledFlag);
  56.    this.highlight_mc.gotoAndStop(!enabledFlag ? "disabled" : "unfocused");
  57. };
  58. FSelectableItemClass.prototype.layoutContent = function(width)
  59. {
  60.    this.attachMovie("FLabelSymbol","fLabel_mc",2,{hostComponent:this.controller});
  61.    this.fLabel_mc._x = 2;
  62.    this.fLabel_mc._y = 0;
  63.    this.fLabel_mc.setSize(width - 2);
  64.    this.fLabel_mc.labelField.selectable = false;
  65. };
  66. FSelectableItemClass.prototype.displayContent = function(itmObj, selected)
  67. {
  68.    var _loc2_ = "";
  69.    if(itmObj.label != undefined)
  70.    {
  71.       _loc2_ = itmObj.label;
  72.    }
  73.    else if(typeof itmObj == "object")
  74.    {
  75.       for(var _loc4_ in itmObj)
  76.       {
  77.          if(_loc4_ != "__ID__")
  78.          {
  79.             _loc2_ = itmObj[_loc4_] + ", " + _loc2_;
  80.          }
  81.       }
  82.       _loc2_ = _loc2_.substring(0,_loc2_.length - 2);
  83.    }
  84.    else
  85.    {
  86.       _loc2_ = itmObj;
  87.    }
  88.    if(this.fLabel_mc.labelField.text != _loc2_)
  89.    {
  90.       this.fLabel_mc.setLabel(_loc2_);
  91.    }
  92.    var _loc5_ = !selected ? this.controller.styleTable.textColor.value : this.controller.styleTable.textSelected.value;
  93.    if(_loc5_ == undefined)
  94.    {
  95.       _loc5_ = !selected ? 0 : 16777215;
  96.    }
  97.    this.fLabel_mc.setColor(_loc5_);
  98. };
  99. FSelectableItemClass.prototype.getItemIndex = function()
  100. {
  101.    return this.controller.getScrollPosition() + this.itemNum;
  102. };
  103. FSelectableItemClass.prototype.getItemModel = function()
  104. {
  105.    return this.controller.getItemAt(this.getItemIndex());
  106. };
  107. FSelectableItemClass.prototype.getHostDataProvider = function()
  108. {
  109.    return this.controller.dataProvider;
  110. };
  111. FSelectableItemClass.prototype.setHighlighted = function(flag)
  112. {
  113.    fade = this.controller.styleTable.fadeRate.value;
  114.    if(fade == undefined || fade == 0 || !flag)
  115.    {
  116.       this.highlight_mc._alpha = !flag ? 0 : 100;
  117.       delete this.onEnterFrame;
  118.    }
  119.    else
  120.    {
  121.       this.fadeN = fade;
  122.       this.fadeX = 1;
  123.       this.highLight_mc._alpha = 20;
  124.       this.onEnterFrame = function()
  125.       {
  126.          this.highLight_mc._alpha = 60 * Math.sqrt(this.fadeX++ / this.fadeN) + 40;
  127.          if(this.fadeX > this.fadeN)
  128.          {
  129.             delete this.onEnterFrame;
  130.          }
  131.       };
  132.    }
  133.    this.highlighted = flag;
  134. };
  135.